package top.hitotright.hdfs;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;


/**
 * hadoop jar xxx.jar top.hitotright.hdfs.FileSystemRead
 * @author hitoTright
 *
 */
public class FileSystemRead {
	public static void main(String[] args) throws IOException {
		String uri = "hdfs://master:9000/user/hadoop/test";
		Configuration conf = new Configuration();
		FileSystem fs = FileSystem.get(URI.create(uri),conf);
		
		InputStream in = null;
		in = fs.open(new Path(uri));
		IOUtils.copyBytes(in, System.out, 4096,false);
		IOUtils.closeStream(in);
	}
}
